package org.example.ssmioc1;

import org.example.ssmioc1.bean.dog;
import org.example.ssmioc1.condition.WindowsCondition;
import org.example.ssmioc1.controller.Usercontroller;
import org.example.ssmioc1.controller.mydatasourceConfig;
import org.example.ssmioc1.dao.UserDao;
import org.example.ssmioc1.pean.Person;
import org.example.ssmioc1.pean.car;
import org.example.ssmioc1.service.hahaservice;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.ConfigurableEnvironment;

import java.util.Map;

//@Impoxrt(CoreConstants.class)
//@Scope("singleton")//单实例只创建一次，在调用一次不用在创建新的一次
@SpringBootApplication
public class SsmIoc1Application {
    public static void main(String[] args) {
         ConfigurableApplicationContext run = SpringApplication.run(SsmIoc1Application.class, args);
         System.out.println("=============================");
         System.out.println(run.getBean(mydatasourceConfig.class));
    }
    public static void text06(String[] args) {

        ConfigurableApplicationContext run = SpringApplication.run(SsmIoc1Application.class, args);
        dog bean = run.getBean(dog.class);
        System.out.println(bean);
    }
    public static void text05(String[] args) {
        ConfigurableApplicationContext run = SpringApplication.run(SsmIoc1Application.class, args);

        System.out.println("=============================");
        hahaservice bean = run.getBean(hahaservice.class);
        System.out.println(bean.getEnvironment());
        System.out.println(bean.getBeanName());
    }
    public static void text04(String[] args) {
        ConfigurableApplicationContext run = SpringApplication.run(SsmIoc1Application.class, args);
        System.out.println("=============================");
        UserDao bean = run.getBean(UserDao.class);
        System.out.println(bean);

    }
    public static void text03(String[] args) {
        ConfigurableApplicationContext run = SpringApplication.run(SsmIoc1Application.class, args);
        System.out.println("=============================");
        Usercontroller bean = run.getBean(Usercontroller.class);
        System.out.println(bean);
    }
//    public static void text02(String[] args) {
//        ConfigurableApplicationContext run = SpringApplication.run(SsmIoc1Application.class, args);
//        ConfigurableEnvironment environment = run.getEnvironment();
//        String   os = environment.getProperty("os");
//        System.out.println(os);
//        Map<String, Person> beansOfType = run.getBeansOfType(Person.class);
//        System.out.println(beansOfType);
//        System.out.println(WindowsCondition.class);
//    }
//    //通过组件扫描获取bean
////多实例在调用一次创建一次
//    public static void text01(String[] args) {
//        ConfigurableApplicationContext run = SpringApplication.run(SsmIoc1Application.class, args);
//        System.out.println("=============================");
//
//        Map<String, Person> beansOfType = run.getBeansOfType(Person.class);
//        System.out.println(beansOfType);
//      //  car bean = run.getBean(Person.class);
//       // System.out.println(bean);
//        System.out.println(WindowsCondition.class);
//
//
//    }

}